/** Initialize all javascript related here **/

function initScript() {
    window.focus();
//    document.getElementById('catiaWBSId').focus();
   initTablePickList()
}

function checkAuditOptionsStatusAfterFilter() {
    if(isTableShowingEmptyList(rightTBody.getElementsByTagName('tr'))) {
        disabledAllAuditOptions()

    } else {
        enabledAuditOptions()
    }
}

function disabledAllAuditOptions() {
    var auditIds = new Array("eliCatiaId",
        "wiresELIBEIId",
        "alsoComparePartNoId",
        "beiCatiaId",
        "multipleCatiaId",
        "alsoShowMatchingDataId",
        "baeCatiaId",
        "historicalCatiaId");

    for (i = 0; i < auditIds.length; i++) {
        toggleAFSelectBooleanCheckbox(auditIds[i], true, false, false)
    }
}

function enabledAuditOptions() {
    var  auditOptions2Enabled = document.getElementById("auditEnabledIds").innerHTML
    var options = auditOptions2Enabled.split(";");
    for (i = 0; i < options.length; i++) {
        if(!isEmpty(options[i])) {
            toggleAFSelectBooleanCheckbox(options[i], false, false, false)
        }
    }
}

function toggleChildSelectBooleanCheckbox(parentSelectBooleanCheckbox, childId) {
    var childText = parentSelectBooleanCheckbox.nextSibling.firstChild.innerHTML;
    if(childText == 'BEI/CATIA - Connector, Position' ||
        childText == 'BEI/CATIA - Connector') {

        toggleAFSelectBooleanCheckbox(childId, !parentSelectBooleanCheckbox.checked, true, false)
    }
}

function toggleAFSelectBooleanCheckbox(id, isDisabled, setChecked, isChecked) {
    var cb = document.getElementById(id);
    if(cb != null) {

        if (id == 'alsoShowMatchingDataId') {
            var beiCatia = document.getElementById('beiCatiaId')
            cb.disabled = !beiCatia.disabled && beiCatia.checked ? isDisabled : true;
            
        } else {
            cb.disabled = isDisabled;
        }

        if(setChecked) {
            cb.checked = isChecked
        }
        cb.nextSibling.firstChild.className = isDisabled ? "x7" : "x6";
    }
}


function hideSelectTableHeader(tBody) {
    var tblContentChildColumns = tBody.getElementsByTagName("tr")[0].getElementsByTagName("th");
    for (var i = 0; i < tblContentChildColumns.length; i++ ) {
        var tdContent = tblContentChildColumns.item(i);
        var imgWidth;
        if (tdContent.width.indexOf('%') == -1) {
            imgWidth = tdContent.width;
        } else {
            imgWidth = tdContent.offsetWidth - 3;
        }
        var newHTML = "<img border='0' src='image/1x1_transparent.png' width='" + imgWidth + "' height='1'/>";
        tdContent.innerHTML = newHTML;
    }
}

/**JS code for picklist in type of table **/
var leftTableId = "baseModelFoundTable"
var rightTableId = "modelSelectedTable"
var leftCheckBoxSuffixId = "modelFoundCB";
var rightCheckBoxSuffixId = "modelSelectedCB";

//Ids to control filtered message
var rightUnfilteredMsgId = "rightUnfilteredMsgId";
var rightFilteredRowNumId1 = "rightFilteredRowNumId1"
var rightFilteredRowNumId2 = "rightFilteredRowNumId2"
var leftUnfilteredMsgId = "leftUnfilteredMsgId";
var leftFilteredRowNumId1 = "leftFilteredRowNumId1"
var leftFilteredRowNumId2 = "leftFilteredRowNumId2"

var leftTBody
var rightTBody

var leftSelectedRowId = "leftSelectedRow"
var rightSelectedRowId = "rightSelectedRow"


var classEven1 = "x2t x62"
var classEven2 = "x2n x62"
var classOdd1 = "x2w x62"
var classOdd2 = "x2o x62"

//table filter/sort/print/save bar ids
var  modelFoundFunctionBtns1 = "modelFoundFunctionBtns1";
//var modelFoundFunctionBtns2= "modelFoundFunctionBtns2";
var modelSelectedFunctionBtns1= "modelSelectedFunctionBtns1";
//var modelSelectedFunctionBtns2= "modelSelectedFunctionBtns2";

//select links
var modelFoundSelectLinks
var modelSelectedSelectLinks

//the value from hidden field to determine if
//LR tables has been filtered
var LEFT_FILTERD = "LEFT_FILTERD";
var RIGHT_FILTERD = "RIGHT_FILTERD";
var LEFT_ASC = "LEFT_ASC";
var RIGHT_ASC = "RIGHT_ASC";
var LEFT_DESC = "LEFT_DESC";
var RIGHT_DESC = "RIGHT_DESC";
var leftFilteredHiddenId = "leftFiltered";
var rightFilteredHiddenId = "rightFiltered";
var EMPTY_LIST = "Empty list.....";

var leftSorted;
var rightSorted;
var emptyListTr;
var movingBtnGroup;
var moveRightBtn
var moveRightDisabledBtn
var moveRightAllBtn
var moveRightAllDisabledBtn
var moveLeftBtn
var moveLeftDisabledBtn
var moveLeftAllBtn
var moveLeftAllDisabledBtn

var FILTER_EQUAL_TO = "equal to";
var FILTER_LESS_THAN = "less than";
var FILTER_LESS_THAN_OR_EQUAL_TO = "less than or equal to";
var FILTER_GREATER_THAN = "greater than";
var FILTER_GREATER_THAN_OR_EQUAL_TO = "greater than or equal to";
var FILTER_NOT_EQUAL_TO = "not equal to";
var FILTER_CONTAINS = "contains";
var FILTER_DOES_NOT_CONTAIN = "does not contain";
var FILTER_STARTS_WITH = "starts with";
var FILTER_DOES_NOT_START_WITH = "does not start with";
var FILTER_TYPE_DEFAULT_VALUE = FILTER_EQUAL_TO;

var leftFilterCriteria
var leftFilterCondition
var rightFilterCriteria
var rightFilterCondition
var leftTotalRow
var rightTotalRow
//var leftFilterHiddenItem
//var rightFilterHiddenItem


function initTablePickList() {
    leftTBody = findTableBody(leftTableId)
    rightTBody = findTableBody(rightTableId)
    movingBtnGroup = document.getElementById("movingBtnGroup");
    moveRightBtn= document.getElementById("moveRightId");
    moveRightDisabledBtn= document.getElementById("moveRightDisabledId");
    moveRightAllBtn= document.getElementById("moveRightAllId");
    moveRightAllDisabledBtn= document.getElementById("moveRightAllDisabledId");
    moveLeftBtn= document.getElementById("moveLeftId");
    moveLeftDisabledBtn= document.getElementById("moveLeftDisabledId");
    moveLeftAllBtn= document.getElementById("moveLeftAllId");
    moveLeftAllDisabledBtn= document.getElementById("moveLeftAllDisabledId");

    leftFilterCriteria = document.getElementById("leftFilterCriteria")
    leftFilterCondition= document.getElementById("leftFilterCondition")
    rightFilterCriteria= document.getElementById("rightFilterCriteria")
    rightFilterCondition= document.getElementById("rightFilterCondition")
    leftTotalRow= document.getElementById("leftTotalRow")
    rightTotalRow= document.getElementById("rightTotalRow")
    modelFoundSelectLinks = document.getElementById("modelFoundSelectLinks")
    modelSelectedSelectLinks = document.getElementById("modelSelectedSelectLinks")
    emptyListTr = document.getElementById("emptyListTr")
    leftSorted = document.getElementById("leftSorted")
    rightSorted=  document.getElementById("rightSorted")

    prepareHiddenValues();
    hideNullRow(rightTBody)
    hideNullRow(leftTBody)
    updateUnfilteredMsg()
    //initialize for moving btn
    checkAllMovingBtn()
    hideSelectTableHeader(leftTBody);
    hideSelectTableHeader(rightTBody);
}

function prepareHiddenValues() {
    leftFilterCriteria.value = document.getElementById("leftFilterCriteriaTXT").innerHTML
    leftFilterCondition.value = document.getElementById("leftFilterConditionTXT").innerHTML
    rightFilterCriteria.value = document.getElementById("rightFilterCriteriaTXT").innerHTML
    rightFilterCondition.value = document.getElementById("rightFilterConditionTXT").innerHTML
    leftTotalRow.value = document.getElementById("leftTotalRowTXT").innerHTML
    rightTotalRow.value = document.getElementById("rightTotalRowTXT").innerHTML
    leftSorted.value = document.getElementById("leftSortedTXT").innerHTML
    rightSorted.value = document.getElementById("rightSortedTXT").innerHTML
    document.getElementById(leftFilteredHiddenId).value = document.getElementById("leftFilteredTXT").innerHTML
    document.getElementById(rightFilteredHiddenId).value = document.getElementById("rightFilteredTXT").innerHTML
}

function matchFilteredCriteria(item, filterCriteriaField, filterConditionField) {

    if(isEmpty(filterCriteriaField.value)) {
        return true;
    }

    var filterCriterias = filterCriteriaField.value.split(";");
    var filterConditions = filterConditionField.value.split(";");
   
    var filterResultOK = true;

    for (k = 0; k < filterCriterias.length; k++) {

        var filterCriteria = trim(filterCriterias[k]);
        var filterCondition = trim(filterConditions[k]);

        if(!isEmpty(filterCriteria)) {

            if (filterCriteria == FILTER_EQUAL_TO) {
                filterResultOK = (item == filterCondition);

            } else if (filterCriteria == FILTER_LESS_THAN) {
                filterResultOK = (item < filterCondition);

            } else if (filterCriteria == FILTER_LESS_THAN_OR_EQUAL_TO) {
                filterResultOK = (item == filterCondition) ||
                (item < filterCondition);

            } else if (filterCriteria == FILTER_GREATER_THAN) {
                filterResultOK = (item > filterCondition);

            } else if (filterCriteria == FILTER_GREATER_THAN_OR_EQUAL_TO) {
                filterResultOK = (item == filterCondition) ||
                (item > filterCondition);

            } else if (filterCriteria == FILTER_NOT_EQUAL_TO) {
                filterResultOK = (item != filterCondition)

            } else if (filterCriteria == FILTER_CONTAINS) {
                filterResultOK = (item.indexOf(filterCondition) >= 0);

            } else if (filterCriteria == FILTER_DOES_NOT_CONTAIN) {
                filterResultOK = (item.indexOf(filterCondition) == -1);

            } else if (filterCriteria == FILTER_STARTS_WITH) {
                filterResultOK = startWidth(item, filterCondition);

            } else {
                filterResultOK = !startWidth(item, filterCondition);
            }

            if(!filterResultOK) {
                return false;
            }
        }
    }

    return filterResultOK;
}


//process for moving btns
function checkAllMovingBtn() {
    checkMoveRightBtn()
    checkMoveLeftBtn()
    checkMoveLeftAllBtn()
    checkMoveRightAllBtn()
    checkExtFunctionBtns()
}

function checkExtFunctionBtns() {
    var leftFilterd = document.getElementById(leftFilteredHiddenId).value;
    var rightFilterd = document.getElementById(rightFilteredHiddenId).value;

    var leftTableEmpty = isEmptyTable(leftTBody);
    var rightTableEmpty = isEmptyTable(rightTBody);

    if(leftTableEmpty) {
        hide(modelFoundSelectLinks)

        if(leftFilterd == LEFT_FILTERD) {
            show(document.getElementById(modelFoundFunctionBtns1))
            //            show(document.getElementById(modelFoundFunctionBtns2))
            hiddenFilterd = "";
            
        } else {
            hide(document.getElementById(modelFoundFunctionBtns1))
        //            hide(document.getElementById(modelFoundFunctionBtns2))
        }

    } else {
        show(document.getElementById(modelFoundFunctionBtns1))
        //        show(document.getElementById(modelFoundFunctionBtns2))
        show(modelFoundSelectLinks)
    }

    if(rightTableEmpty) {
        hide(modelSelectedSelectLinks)
        if(rightFilterd == RIGHT_FILTERD) {
            show(document.getElementById(modelSelectedFunctionBtns1))
            //            show(document.getElementById(modelSelectedFunctionBtns2))
            hiddenFilterd = "";
            
        } else {
            hide(document.getElementById(modelSelectedFunctionBtns1))
        //            hide(document.getElementById(modelSelectedFunctionBtns2))
        }
    } else  {
        show(document.getElementById(modelSelectedFunctionBtns1))
        //        show(document.getElementById(modelSelectedFunctionBtns2))
        show(modelSelectedSelectLinks)
    }
}

function checkMoveRightBtn() {
    onoffMoveBtn(leftTBody, moveRightBtn, moveRightDisabledBtn)
}

function checkMoveLeftBtn() {
    onoffMoveBtn(rightTBody, moveLeftBtn, moveLeftDisabledBtn)
}

function checkMoveLeftAllBtn() {
    checkMoveAllBtn(rightTBody, moveLeftAllBtn, moveLeftAllDisabledBtn);
}

function checkMoveRightAllBtn() {
    checkMoveAllBtn(leftTBody, moveRightAllBtn, moveRightAllDisabledBtn);
}

function checkMoveAllBtn(srcTBody, moveAll, moveAllDiabled) {
    if(isEmptyTable(srcTBody)) {
        toggleMovingBtn(moveAll, moveAllDiabled)

    } else {
        toggleMovingBtn(moveAllDiabled, moveAll)
    }
}

function addEmptyListTR(tBody, rows) {
    var cloned = emptyListTr.cloneNode(true);
    tBody.insertBefore(cloned, rows[1])
    show(cloned)
}

function removeEmptyList(tBody) {
    if(isTableShowingEmptyList(tBody.getElementsByTagName('tr'))) {
        tBody.removeChild(document.getElementById('emptyListTr'))
    }
}

function isEmptyTable(tBody) {
    var rows = tBody.getElementsByTagName('tr');

    if(isTableShowingEmptyList(rows)) {
        return true;
    }

    for (i = 1; i < rows.length; i++) {
        var row = rows[i];
        if(isShow(row)) {
            return false;
        }
    }

    addEmptyListTR(tBody, rows)

    return true;
}

function onoffMoveBtn(tBody, moveBtn, moveBtnDisabled) {
    var rows = tBody.getElementsByTagName('tr');
    
    for (i = 1; i < rows.length; i++) {
        var row = rows[i];
        if(isShow(row)) {

            if(i != 1 || !isTableShowingEmptyList(rows)) {
                if(row.firstChild.firstChild.checked) {
                    toggleMovingBtn(moveBtnDisabled, moveBtn)
                    return;
                }
            }
        }
    }
    toggleMovingBtn(moveBtn, moveBtnDisabled)
}

function toggleMovingBtn(moveBtn, moveBtnDisabled) {
    var childs = movingBtnGroup.childNodes;
    for(i = 0; i < childs.length; i++) {
        if(childs[i] == moveBtn) {
            show(moveBtnDisabled)
            hide(moveBtn)
            //            movingBtnGroup.replaceChild(moveBtnDisabled, moveBtn)
            return
        }
    }
}

//end process for moving btns


function updateUnfilteredMsg() {
    var leftRowNum = getNumVisibleRow(leftTBody);
    var rightRowNum = getNumVisibleRow(rightTBody)

    if(document.getElementById(leftFilteredRowNumId1) != null) {
        document.getElementById(leftFilteredRowNumId1).innerHTML = "&nbsp;" + leftRowNum + "&nbsp;"
        document.getElementById(leftFilteredRowNumId2).innerHTML = "&nbsp;" + leftTotalRow.value + "&nbsp;"
    }

    if(document.getElementById(leftUnfilteredMsgId) != null) {
        document.getElementById(leftUnfilteredMsgId).innerHTML = leftRowNum + "&nbsp";
    }
    

    if(document.getElementById(rightFilteredRowNumId1) != null) {
        document.getElementById(rightFilteredRowNumId1).innerHTML ="&nbsp;" + rightRowNum + "&nbsp;"
        document.getElementById(rightFilteredRowNumId2).innerHTML =  "&nbsp;" + rightTotalRow.value + "&nbsp;"
    }
    
    if(document.getElementById(rightUnfilteredMsgId) != null) {
        document.getElementById(rightUnfilteredMsgId).innerHTML =  rightRowNum + "&nbsp;"
    }
}

function isTableShowingEmptyList(rows) {
    return  rows[1].childNodes[1].innerHTML == EMPTY_LIST
}

function getNumVisibleRow(tBody) {
    var numRow = 0
    var rows = tBody.getElementsByTagName('tr');

    if(isTableShowingEmptyList(rows)) {
        return 0;
    }

    for (i = 1; i < rows.length; i++) {
        if(isShow(rows[i])) {
            numRow += 1;
        }
    }

    return numRow;
}

function pullLRSelectedRow() {
    pullSelectedRow(leftTBody, true)
    pullSelectedRow(rightTBody, false)
}

function pullSelectedRow(tBody, isLeft) {
    var rows = tBody.getElementsByTagName('tr');

    var hiddenSelected = isLeft ? document.getElementById(leftSelectedRowId)
    : document.getElementById(rightSelectedRowId)

    hiddenSelected.value = "";

    for (i = isTableShowingEmptyList(rows) ? 2 : 1; i < rows.length; i++) {
        var row = rows[i];
        var showed = isShow(row);

        if(showed || row.firstChild.firstChild.checked) {
            hiddenSelected.value += row.firstChild.firstChild.value + ";"
        }
    }
}

function hideNullRow(tBody) {
    var rows = tBody.getElementsByTagName('tr');
    for (i = 1; i < rows.length; i++) {

        if(rows[i].firstChild.firstChild != null) {
            rows[i].firstChild.firstChild.checked = false;
        }

        if(isWhitespace((rows[i].childNodes[1].innerHTML))) {
            hide(rows[i]);
        }
    }
}

function hideAllRow(tBody) {
    var rows = tBody.getElementsByTagName('tr');
    for (i = 1; i < rows.length; i++) {
        rows[i].firstChild.firstChild.checked = false
        hide(rows[i]);
    }
}


function moveRight(moveAll) {
    if(moveAll) {
        moveRows(leftTBody, rightTableId, rightCheckBoxSuffixId, true)

    } else {
        moveRows(leftTBody, rightTableId, rightCheckBoxSuffixId, false)
    }

    if(!isTableShowingEmptyList(rightTBody.getElementsByTagName('tr'))) {
        enabledAuditOptions()
    }

    updateUnfilteredMsg()
    checkAllMovingBtn()
    checkExtFunctionBtns()

    if(isTableShowingEmptyList(rightTBody.getElementsByTagName('tr'))) {
        disabledAllAuditOptions()
    }
}

function moveLeft(moveAll) {
    if(moveAll) {
        moveRows(rightTBody, leftTableId, leftCheckBoxSuffixId, true)

    } else {
        moveRows(rightTBody, leftTableId, leftCheckBoxSuffixId, false)
    }
    updateUnfilteredMsg()
    checkAllMovingBtn()
    checkExtFunctionBtns()

    if(isTableShowingEmptyList(rightTBody.getElementsByTagName('tr'))) {
        disabledAllAuditOptions()
    }
}

function moveRows(srcTBody, targetTableId, targetCBSuffixId, isAllRow) {
    var targetTbody = findTableBody(targetTableId)
    removeEmptyList(targetTbody);

    var rows = srcTBody.getElementsByTagName('tr');
    
    var moveToLeft = (targetTableId == leftTableId);
    var sortDirection = getSortDirection(moveToLeft);
    var isAscSort = false //DESC
    var isTargetTableSorted = sortDirection != null
    if(isTargetTableSorted) {
        isAscSort = moveToLeft ? sortDirection == LEFT_ASC : sortDirection == RIGHT_ASC
    }

    var cb;
    for (i = 1; i < rows.length; i++) {
        cb = rows[i].firstChild.firstChild;
        var eqipNOValue = getRowData(rows[i]);
        if(((isAllRow && isShow(rows[i]))|| cb.checked ) && !isEmpty(eqipNOValue)) {
            
            toggleRowPair(cb.id, cb.value,  targetTableId, targetCBSuffixId,
                eqipNOValue, moveToLeft, isTargetTableSorted);
                
            cb.checked = false;
        }
    }

    if(isTargetTableSorted) {
        sortTable(targetTbody, isAscSort)
    }

    //    if(!isAllRow) {
    checkRowEvenOdd(null, rows, 0, true)
    checkRowEvenOdd(null, targetTbody.getElementsByTagName('tr'), 0, true)
//    }
}

function findTableBody(tableId) {
    hide(document.getElementById(tableId).childNodes[0])
    var theTable = document.getElementById(tableId).childNodes[1]
    return theTable.tBodies[0]
}

function toggleRowPair(sourceCB, sourceCBIndex, targetTableId, 
    targetCBSuffixId, srcEquipNo, moveToLeft, isTargetTableSorted){
    
    if(!isEmpty(srcEquipNo)) {
        //        var moveToLeft = (targetTableId == leftTableId);
        var filterCriteria
        var filterCondition
        var srcTotalRow
        var targetTotalRow

        if(moveToLeft) {
            filterCriteria = leftFilterCriteria;
            filterCondition = leftFilterCondition
            srcTotalRow = rightTotalRow
            targetTotalRow = leftTotalRow;
            
        } else {
            filterCriteria = rightFilterCriteria;
            filterCondition = rightFilterCondition
            srcTotalRow = leftTotalRow
            targetTotalRow = rightTotalRow;
        }
        srcTotalRow.value--;
        targetTotalRow.value++;

        var targetCBId = targetTableId + ":" + sourceCBIndex + ":" + targetCBSuffixId;
        var srcRow = getRowByCheckBoxId(sourceCB);
        var targetRow = getRowByCheckBoxId(targetCBId);
      
        var targetTbody = findTableBody(targetTableId);
        
        hide(srcRow)

        var targetRows = targetTbody.getElementsByTagName('tr');

        if(targetRows.length > 2 && !isTargetTableSorted) {
            targetTbody.removeChild(targetRow);
            targetTbody.insertBefore(targetRow, targetRows[1]);
        }

        if(matchFilteredCriteria(srcEquipNo, filterCriteria, filterCondition)) {
            
            setRowData(targetRow, srcEquipNo)
            //            checkRowEvenOdd(targetRow, targetRows, 2, false)
            show(targetRow)
            srcRow.firstChild.firstChild.checked = false;

        } else {
            srcRow.firstChild.firstChild.checked = false;
            targetRow.firstChild.firstChild.checked = true;
        }
    }
}

function getSortDirection(isLeft) {
    var direction;

    if(isLeft) {
        direction = trim(leftSorted.value);

    } else {
        direction = trim(rightSorted.value);
    }

    return isEmpty(direction) ? null : direction
}

function sortTable(targetTbody ,isAscSort) {
    var direction = isAscSort ? 1 : -1
    var rowNodeList = targetTbody.getElementsByTagName('tr');
    var rowArray2Sort = new Array();
    
    for(k = 1; k < rowNodeList.length; k++) {
        rowArray2Sort[k] = rowNodeList[k]
    }

    rowArray2Sort.sort(function (a, b) {
        var returnVal = 0;

        if(isShow(a) && isShow(b)) { 
            var aVal = getRowData(a).toLowerCase();
            var bVal = getRowData(b).toLowerCase();

            returnVal = aVal > bVal ? 1 : (aVal < bVal ? -1 : 0)
        }
        return returnVal * direction;
    });


    while(targetTbody.childNodes[1]) {
        targetTbody.removeChild(targetTbody.childNodes[1])
    }

    for(j = 0; j < rowArray2Sort.length; j++) {
        if(rowArray2Sort[j]) {
            targetTbody.appendChild(rowArray2Sort[j])
        }
    }
}

function checkRowEvenOdd(row, rowList, nextRowId, loopAllRow) {

    if(loopAllRow) {
        var preStyle = classEven1;
        for(j = 1; j < rowList.length - 1; j++) {
            
            if(isShow(rowList[j])) {
                
                if(rowList[j].firstChild.className == preStyle) {
                
                    if(rowList[j].firstChild.className == classEven1 ) {
                        rowList[j].firstChild.className = classOdd1
                        rowList[j].childNodes[1].className = classOdd2

                    } else {
                        rowList[j].firstChild.className = classEven1
                        rowList[j].childNodes[1].className = classEven2
                    }
                }

                preStyle = rowList[j].firstChild.className;
            }
        }
    } else {
        if(rowList[nextRowId] != null) {
            if(rowList[nextRowId].firstChild.className == classEven1) {
                row.firstChild.className = classOdd1
                row.childNodes[1].className = classOdd2

            } else {
                row.firstChild.className =  classEven1
                row.childNodes[1].className =   classEven2
            }
        }
    }
}

//get the column value of given row
//In EquipmentAudit, it's Equipment Number column
function getRowData(row) {
    return row.childNodes[1].innerHTML;
}

function setRowData(row, equipNoValue) {
    row.childNodes[1].innerHTML = equipNoValue
}

function toggleRow(row) {
    if (row.style.display == '')
        row.style.display = 'none';
    else row.style.display = '';
}

function isShow(row) {
    return row.style.display == '' ? true : false
}

function show(row) {
    if(row != null) {
        row.style.display = '';
    }
}

function hide(row) {
    if(row != null) {
        row.style.display = 'none';
    }
}

function getRowByCheckBoxId(cbId) {
    var cb = document.getElementById(cbId);
    return cb != null ? cb.parentNode.parentNode : null;
}

